From d905bf6570797c4c0b711d3b4526c6b622993538 Mon Sep 17 00:00:00 2001 From: Junpeng Qiu Date: Wed, 27 Apr 2016 14:45:41 -0400 Subject: [PATCH] Fix god mode advice See https://github.com/justbur/emacs-which-key/pull/115 --- which-key.el | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/which-key.el b/which-key.el index fcb762809f5..6788d0168af 100644 --- a/which-key.el +++ b/which-key.el @@ -519,12 +519,12 @@ problems at github.") "Holds key string to use for god-mode support.") (defadvice god-mode-lookup-command - (before which-key--god-mode-lookup-command-advice disable) - (setq which-key--god-mode-key-string (ad-get-arg 0))) - -(defadvice god-mode-self-insert - (after which-key--god-mode-self-insert-advice disable) - (which-key--hide-popup)) + (around which-key--god-mode-lookup-command-advice disable) + (setq which-key--god-mode-key-string (ad-get-arg 0)) + (unwind-protect + ad-do-it + (when (bound-and-true-p which-key-mode) + (which-key--hide-popup)))) (defun which-key-enable-god-mode-support (&optional disable) "Enable support for god-mode if non-nil. This is experimental, @@ -533,21 +533,13 @@ problems at github. If DISABLE is non-nil disable support." (interactive "P") (setq which-key--god-mode-support-enabled (null disable)) (if disable - (progn - (ad-disable-advice - 'god-mode-lookup-command - 'before 'which-key--god-mode-lookup-command-advice) - (ad-disable-advice - 'god-mode-self-insert - 'after 'which-key--god-mode-self-insert-advice)) + (ad-disable-advice + 'god-mode-lookup-command + 'around 'which-key--god-mode-lookup-command-advice) (ad-enable-advice 'god-mode-lookup-command - 'before 'which-key--god-mode-lookup-command-advice) - (ad-enable-advice - 'god-mode-self-insert - 'after 'which-key--god-mode-self-insert-advice)) - (ad-activate 'god-mode-lookup-command) - (ad-activate 'god-mode-self-insert)) + 'around 'which-key--god-mode-lookup-command-advice)) + (ad-activate 'god-mode-lookup-command)) ;;;###autoload (define-minor-mode which-key-mode -- 2.30.2